package com.Players;

import android.util.Log;

import com.Others.GameObject;
import com.badlogic.androidgames.framework.gl.Animation;
import com.badlogic.androidgames.framework.gl.SpriteBatcher;
import com.badlogic.androidgames.framework.gl.TextureRegion;
import com.badlogic.androidgames.framework.math.OverlapTester;
import com.badlogic.androidgames.framework.math.Vector2;
import com.baseinfinityrun.Assets;

public abstract class Player extends GameObject
{
	public float animTime;
	public Vector2 accel, velo, jump;
	
	protected Object playerState;
	
	public Player(float x, float y, float w, float h)
	{
		super(x, y, w, h);
		this.tag = "player";
		playerState = new Object();
		
		accel = new Vector2();
		velo = new Vector2();
		animTime = 0;
	}

	@Override
	public void Update(float deltaTime) 
	{
		super.Update(deltaTime);
		
		WalkingAnim(deltaTime);
		this.accel.add(2 * deltaTime, 0);
		
		this.velo.set(this.accel);
		this.position.add(velo);
		this.accel.set(0, 0);
	}
	
	public abstract void TouchLeft();
	
	public abstract void TouchRight();
	
	public abstract String GetState();
	
	public abstract void SetState(int state);
	
	
	protected void WalkingAnim(float deltaTime)
	{
		animTime += deltaTime * 2;		
	}
	
	@Override
	public void Draw(SpriteBatcher batcher) 
	{
		batcher.beginBatch(Assets.playerAtlas);
        TextureRegion keyFrame = this.animation.getKeyFrame(this.animTime, Animation.ANIMATION_LOOPING);
        batcher.drawSprite(this.rectCollider.lowerLeft.x, this.rectCollider.lowerLeft.y, -this.rectCollider.width, this.rectCollider.height, keyFrame);
        batcher.endBatch();  
	}

}
